<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />
    <ex_super_table_page v-bind="option" ref="SuperTablePage" :data="tableData"  @selection-change="e => selection = e"
      >
    </ex_super_table_page>

    <ex_super_dialog_form ref="editDialogRef" v-bind="edit_dialog" @afterSubmitSuccess="e => {
      tableData.push(e)
    }">
    </ex_super_dialog_form>
    <!-- @afterSubmitSuccess="$refs['SuperTablePage'].reload()" -->
  </div>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';
import emitOnFunction from '@/mixin/emit-on-function';

import page_table_model_manage from '@/mixin/page_table_model_manage';

// import unclaimed_dialog from './dialog/unclaimed_dialog.vue'
let emitKey = 'returngood>address'
export default {
  title: 'label_return_good_address',
  mixins: [superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage],
  // components: { unclaimed_dialog },
  data() {
    return {
      tableData:[],
      selection: [],
      option: {
        actionExtra: [
          {
            label: 'label_add_address', attrs: { type: "primary" }, click: () => {
              this.$refs.editDialogRef.showNew({ title: this.$tt("label_add_address") })
            }
          },
        ],
        table: {
          // url: "/oms-api/client/InboundReceivingClientRpc/selectPage.json",
          model: this.init_table_model(),
        },
      },
      edit_dialog: {
        customClass: 'dialog_auto',

        // submitUrl: "/tms-api/task/TmsBaseAnomalyRpc/save.json",
        // detailUrl: "/tms-api/task/TmsBaseAnomalyRpc/getAllCustomer.json",
        // submitDataHandle: (data) => {
        //   return data
        // },
        form: {
          itemClass: "form_item_default",
          inputClass: "form_input_default",
          // formClass: "form_default_col2 flex_row_wrap",
          default: {},
          model: [
            { key: 'name', label: 'label_address_name' },
            { key: 'as', label: 'label_address_as' },
            { key: 'region', label: 'label_region', },
            { key: 'address', label: 'label_detail_address', attrs: { type: 'textarea' } },

            { key: 'postCode', label: 'label_post_code' },
          ],
          rules: {
            anomalyClassifyId: { required: true, message: this.$tt('tip_can_no_empty'), trigger: 'blur' },
          },
        }
      },
    };
  },
  methods: {
    option_table_model() {
      return [
        { key: 'name', label: 'label_address_name', 'show-overflow-tooltip': true, },
        { key: 'as', label: 'label_address_as', 'show-overflow-tooltip': true, },
        { key: 'region', label: 'label_region', 'show-overflow-tooltip': true, },
        { key: 'address', label: 'label_detail_address', 'show-overflow-tooltip': true, },
        { key: 'postCode', label: 'label_post_code', 'show-overflow-tooltip': true, },
        { key: 'updateTime', label: 'label_update_time', 'show-overflow-tooltip': true, },
        {
          type: 'operate', width: 160, fixed: 'right', operate: [
            {
              label: 'label_edit', click: (row) => {
                this.$refs.editDialogRef.showNew({
                  title: this.$tt("label_edit_address"),
                  data: row,
                  onlySetData: true,
                })
              }
            },
            {
              label: 'label_delete',
              click: (row, i, list) => {
                // console.log(row,i,list)
                this.tableData.splice(i, 1)
                // list.splice(i, 1)
              }
            },
          ]
        }
      ]
    },

  }
};

</script>
<style lang="less" scoped>
.dialogTable {
  margin-top: 16px;
}
</style>
